#include "WinUnit.h"
#include "PositionPatcher.h"
#include "Player.h"
#include <list>

using namespace std;

namespace
{
	PositionPatcher patcher;
}

BEGIN_TEST(HeadsUpTest)
{	
	list<Player> headsUpPlayers;
	Player player1 = Player("player1", 1, 100);
	headsUpPlayers.push_back(player1);
	Player player2 = Player("player2", 4, 100);
	headsUpPlayers.push_back(player2);

	patcher.Patch(headsUpPlayers, 1);

	list<Player>::iterator it = headsUpPlayers.begin();
	list<Player>::iterator it2 = headsUpPlayers.begin();
	it2++;

	WIN_ASSERT_TRUE(
		it->IsButton() == true
		&& it->IsBb() == false
		&& it->IsSb() == true
		&& it2->IsButton() == false
		&& it2->IsBb() == true
		&& it2->IsSb() == false
	);
}
END_TEST

BEGIN_TEST(NonHeadsUpTest)
{	
	list<Player> players;
	Player player1 = Player("player1", 1, 100);
	players.push_back(player1);
	Player player2 = Player("player2", 3, 100);
	players.push_back(player2);
	Player player3 = Player("player3", 5, 100);
	players.push_back(player3);
	Player player4 = Player("player4", 6, 100);
	players.push_back(player4);
	
	patcher.Patch(players, 1);
	list<Player>::iterator it = players.begin();
	list<Player>::iterator it2 = players.begin();
	it2++;
	list<Player>::iterator it3 = players.begin();
	it3++; it3++;
	list<Player>::iterator it4 = players.begin();
	it4++; it4++; it4++;	

	WIN_ASSERT_TRUE(
		it->IsBb() == false
		&& it->IsSb() == false
		&& it->IsButton() == true
		&& it2->IsBb() == false
		&& it2->IsSb() == true
		&& it2->IsButton() == false
		&& it3->IsBb() == true
		&& it3->IsSb() == false
		&& it3->IsButton() == false
		&& it4->IsBb() == false
		&& it4->IsSb() == false
		&& it4->IsButton() == false
	);
}
END_TEST

BEGIN_TEST(NonHeadsUpWrapAroundTest)
{	
	list<Player> players;
	Player player1 = Player("player1", 1, 100);
	players.push_back(player1);
	Player player2 = Player("player2", 3, 100);
	players.push_back(player2);
	Player player3 = Player("player3", 5, 100);
	players.push_back(player3);
	Player player4 = Player("player4", 6, 100);
	players.push_back(player4);
	
	patcher.Patch(players, 5);
	list<Player>::iterator it = players.begin();
	list<Player>::iterator it2 = players.begin();
	it2++;
	list<Player>::iterator it3 = players.begin();
	it3++; it3++;
	list<Player>::iterator it4 = players.begin();
	it4++; it4++; it4++;	

	WIN_ASSERT_TRUE(
		it->IsBb() == true
		&& it->IsSb() == false
		&& it->IsButton() == false
		&& it2->IsBb() == false
		&& it2->IsSb() == false
		&& it2->IsButton() == false
		&& it3->IsBb() == false
		&& it3->IsSb() == false
		&& it3->IsButton() == true
		&& it4->IsBb() == false
		&& it4->IsSb() == true
		&& it4->IsButton() == false
	);
}
END_TEST
